part of my_base_lib;

abstract class BaseWidgetState<T extends StatefulWidget> extends State<T> with EventBus{
  bool isLoading = false;

  void showLoadingDialog({bool cancelable = true})async{
    if(!isLoading){
      setState(() {
        isLoading = true;
      });

      await showDialog(
          context: context,
          barrierDismissible: cancelable,
          builder: (context) => ProgressDialog(cancelable: cancelable));
      isLoading = false;
    }

  }

  void hideLoadingDialog() {
    if (isLoading) {
      setState(() {
        isLoading = false;
      });
      Navigator.of(context).pop();
    }
  }


  @override
  void initState() {
    LogUtils.d('*************  ${widget.runtimeType}   *******************',tag: '界面启动');
    super.initState();
    registerEventBus();
  }

  @override
  void deactivate () {
    super.deactivate ();
    HttpUtils.cancel(this);
  }
}



